//
//  DeleteBar.m
//  FlyGift
//
//  Created by lanou3g on 15/7/17.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "DeleteBar.h"
/**
 点击小箭头弹出的页面 可以选中删除的
 */

@implementation DeleteBar

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self makeNewBar];
        self.hidden = YES;
    }
    return self;
}



- (void)makeNewBar
{
    self.backgroundColor = KColor(238, 238, 238, 1);
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 60, 30)];
    label.font = [UIFont systemFontOfSize:14];
    label.textColor = KColor(111, 111, 111, 1);
    label.text = @"我的频道";
    [self addSubview:label];
    
    
    // 点击才出来的label
    if (!self.hitText)
    {
        self.hitText = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(label.frame) + 10, 10, 100, 11)];
        self.hitText.font = [UIFont systemFontOfSize:11];
        self.hitText.text = @"拖拽可以排序";
        self.hitText.textColor = KColor(170, 170, 170, 1);
        self.hitText.hidden = YES;
        [self addSubview:self.hitText];
    }
    
    // 点击排序的button
    if (!self.sortBtn)
    {
        self.sortBtn = [[UIButton alloc]initWithFrame:CGRectMake(kScreenWidth - 100, 5, 50, 20)];
        [self.sortBtn setTitle:@"排序" forState:UIControlStateNormal];
        [self.sortBtn setTitleColor:kMainColor forState:UIControlStateNormal];
        self.sortBtn.titleLabel.font = [UIFont  systemFontOfSize:13];
        self.sortBtn.layer.cornerRadius = 5.0;
        self.sortBtn.layer.masksToBounds = YES;
        self.sortBtn.layer.borderColor = kMainColor.CGColor;
        self.sortBtn.layer.borderWidth = 0.5;
        [self.sortBtn addTarget:self action:@selector(sortBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_sortBtn];
        
    }
    
}
#pragma mark - 点击排序button触发的事件
- (void)sortBtnAction:(UIButton *)sender
{
    if (sender.selected)
    {
        [sender setTitle:@"排序" forState:UIControlStateNormal];
        self.hitText.hidden = YES;
    }
    else
    {
        [sender setTitle:@"完成" forState:UIControlStateNormal];
        self.hitText.hidden = NO;
    }
    // 切换被选中的状态
    sender.selected = !sender.selected;
    
    // 发送一个通知
    [[NSNotificationCenter defaultCenter] postNotificationName:@"sortBtnAction" object:sender userInfo:nil];
}
@end
